package org.com.blbl.bean;

import org.apache.hadoop.io.WritableComparable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

public class BiliSortBean implements WritableComparable<BiliSortBean> {

    //每周最大期数
    private long weeklyBigNum;

    //空参构造
    public BiliSortBean() {
    }

    //有参构造
    public BiliSortBean(long weeklyBigNum) {
        this.weeklyBigNum = weeklyBigNum;
    }

    //get和set方法
    public long getWeeklyBigNum() {
        return weeklyBigNum;
    }

    public void setWeeklyBigNum(long weeklyBigNum) {
        this.weeklyBigNum = weeklyBigNum;
    }

    public void set(long weeklyBigNum) {
        setWeeklyBigNum(weeklyBigNum);
    }

    //toString方法
    @Override
    public String toString() {
        return weeklyBigNum + "\t";

    }

    //对比方法
    //这个方法接收一个CrimeSortBean对象o作为参数，并返回一个整数值来表示比较结果
    @Override
    public int compareTo(BiliSortBean o) {
        if(this.weeklyBigNum > o.getWeeklyBigNum()){
            return -1;
        }else if(this.weeklyBigNum < o.getWeeklyBigNum()){
            return 1;
        }else {
            return 0;
        }
    }

    //序列化方法
    @Override
    public void write(DataOutput dataOutput) throws IOException {
        dataOutput.writeLong(weeklyBigNum);
    }

    //反列化方法
    @Override
    public void readFields(DataInput dataInput) throws IOException {
        this.weeklyBigNum = dataInput.readLong();
    }
}
